﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.Common;
using LTJ.Entity;
using LTJ.FrameWork;
using System.Data;

namespace uswinweb.datacontrol
{
    public partial class pop_coutryList : System.Web.UI.UserControl
    {
        public DataTable nationalTab = new DataTable();
        public string coutry_strWhere = " 1=1 ";
        public int coutry_pagesize = 10;
        public int coutry_pageindex = SASRequest.GetInt("currentPage", 1);
        public string coutry_action = SASRequest.GetString("coutry_action");
        public string coutry_parpms = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("coutry_parms").Trim());
        public string coutry_searchtype = SASRequest.GetString("coutry_seatype").Trim();
        public string coutry_tcode = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("coutry_tcode").Trim());
        public string coutry_name = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("coutry_name").Trim());
        public string coutry_ename = LTJ.Common.Utils.UrlDecode(SASRequest.GetString("coutry_ename").Trim());
        public string coutry_pageList = "";
        public string coutry_orderstr = " order by id asc ";
        public string coutry_bcode = "country";
        public pop_coutryList()
        {
            int recordcount = 0;
            if (coutry_action == "search")
            {
                if (coutry_searchtype != "")
                {
                    //if (coutry_searchtype == "tcode")
                    //{
                    //    coutry_strWhere += " and " + coutry_searchtype + " like '%" + coutry_tcode + "%' ";
                    //}
                    //if (coutry_searchtype == "name")
                    //{
                    //    coutry_strWhere += " and " + coutry_searchtype + " like '%" + coutry_name + "%' ";
                    //}
                    //if (coutry_searchtype == "ename")
                    //{
                    //    coutry_strWhere += " and " + coutry_searchtype + " like '%" + coutry_ename + "%' ";
                    //}
                    if (coutry_tcode != "")
                    {
                        coutry_strWhere += " and tcode like '%" + coutry_tcode + "%' ";
                    }
                    if (coutry_name != "")
                    {
                        coutry_strWhere += " and name like '%" + coutry_name + "%' ";
                    }
                    if (coutry_ename != "")
                    {
                        coutry_strWhere += " and ename like '%" + coutry_ename + "%' ";
                    }
                }
                else
                {
                    coutry_strWhere += " and name like '%" + coutry_parpms + "%' ";
                }
            }
            if (coutry_bcode != "")
            {
                coutry_strWhere += " and code='" + coutry_bcode + "'";
            }
            recordcount = BaseDatas.GetBaseDataCount(coutry_strWhere);
            nationalTab = BaseDatas.GetBaseDataByPage(coutry_pageindex, coutry_pagesize, coutry_strWhere, coutry_orderstr);
            coutry_pageList = GetPageList(recordcount, coutry_pagesize, coutry_pageindex);
        }
        public string GetPageList(int recordcount, int pagesize, int currentpage)
        {
            if (SASRequest.GetInt("postnumber", 0) > 0)
            {
                return LTJ.Common.Utils.LuffyPage3(recordcount, pagesize, currentpage, "pop_coutryList.ascx", "postnumber=" + SASRequest.GetInt("postnumber", 0), "showdata2");
            }
            else
            {
                return LTJ.Common.Utils.LuffyPage3(recordcount, pagesize, currentpage, "pop_coutryList.ascx", "coutry_action=" + coutry_action + "&coutry_seatype=" + coutry_searchtype + "&coutry_parms=" + coutry_parpms + "&coutry_tcode=" + coutry_tcode + "&coutry_name=" + coutry_name + "&coutry_enmae=" + coutry_ename + "", "showdata2");
            }
        }
    }
}